<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script type="text/javascript">
			var random = parseInt(Math.random() * 100 + 1);
			function cal(){
				var numInput = parseInt(document.getElementById("numId").value);
				if(isNaN(numInput)){
					resultId.innerHTML = "请输入数字";
					return;
				}
				if(numInput > random){
					resultId.innerHTML = "<span>大了</span>"
				}else if(numInput < random){
					resultId.innerHTML = "<span>小了</span>"
				}else {
					resultId.innerHTML = "<span>猜对了</span>"
				}
			}
		</script>
	</head>
	<body>
		<input type="text" id="numId" />
		<input type="button" value="猜" onclick="cal()"/>
		<span id="resultId"></span>
	</body>
</html>
